classdef Import < preparser.control.BaseClass
    properties
        FileName = '' % Name of file to be imported.
    end
    
    
    
    
    methods
        function this = Import(varargin)
            if isempty(varargin)
                return
            end
            this.FileName = varargin{1};
        end
        
        
        
        
        function c = writeFinal(this, p, varargin)
            import preparser.Preparser;
            import preparser.control.Control;
            fileName = this.FileName;
            if ~isempty(p.StoreForCtrl) && ~isempty(strfind(fileName, '?'))
                fileName = Control.substituteForCtrl(fileName, p);
            end
            fileName = strtrim(fileName);
            if ~isempty(fileName)
                [c, ~, exportable, ctrlParameters] = ...
                    Preparser.parse(fileName, [ ], p.Assigned);
                add(p, ctrlParameters, exportable);
                % Reset file name back to caller file.
                exception.Preparser.storeFileName(p.FileName);
            else
                c = '';
            end
        end
    end
end
